package org.ccf.chamberlain;

import java.util.Locale;

import org.ccf.chamberlain.business.BusinessManager;
import org.ccf.chamberlain.model.Category;
import org.ccf.chamberlain.view.DetailTabActivity;
import org.ccf.chamberlain.view.DialogFactroy;
import org.ccf.chamberlain.view.LogsListActivity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Main extends Activity
{
	public static final int DIALOG_IN = 1;
	public static final int DIALOG_OUT = 2;
	public static final int DIALOG_QUREY = 3;
	public static final int DIALOG_DETAIL = 4;
	DialogFactroy dialogFactroy = DialogFactroy.buildDialogFactroy();

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		System.out.println(Locale.getDefault()); 
		initButton();
		
	}

	private void initButton()
	{
		Button btn_in = (Button) findViewById(R.id.in);
		btn_in.setOnClickListener(new OnClickListener()
		{
			public void onClick(View v)
			{
				dialogFactroy.buildCategoryDialog(Main.this,Category.TYPE_IN).show();
			}

		});
		
		
		Button btn_out = (Button) findViewById(R.id.out);
		btn_out.setOnClickListener(new OnClickListener()
		{
			public void onClick(View v)
			{
				dialogFactroy.buildCategoryDialog(Main.this,Category.TYPE_OUT).show();
			}

		});
		
		Button btn_detail = (Button) findViewById(R.id.detail);
		btn_detail.setOnClickListener(new OnClickListener()
		{
			public void onClick(View v)
			{
				Intent logIntent =new Intent(Main.this, DetailTabActivity.class);
				startActivity(logIntent);
			}

		});
	}

	@Override
	protected void onDestroy()
	{
		// TODO Auto-generated method stub
		super.onDestroy();
		BusinessManager.getInstance(this).closeDB();
		//BusinessManager.m
		Log.v("DB", "DB Close");
		
	}

}